'''
------------------------------------------------------------------------------
    Autor:             terrasky
    Date:              2024-09-20
    Ver:               v1.0 
    copyright: (c) 2024 by Terrasky All rights reserved.

------------------------------------------------------------------------------
'''
# :env:       Python 3.8.7
## FileStruct ################################################################
# 1     CheckTool.py                    主程序
# 2     cad.py                          cad相关模块
# 3     config.py                       程序配置模块
# 4     gtypes.py                       与cad通信需要的数据结构转换模块
# 5     logger.py                       处理日志模块
# 6     printUI.py                      处理程序界面模块
# 7     addDataDialog.py                添加菜单界面模块
# 8     QEnterPlainTextEdit.py          自定义特殊组件
# ------------------------------------------------------------------------------

import json
from enum import Enum

# 枚举
class appModel(Enum):
    '''程序进程管理模式标志'''
    NET = 0  # 网路模式：读取mysql数据库
    FILE = 1  # 本地文件读取模式：缺少入库功能
    READ = 2  # 只读模式：用于修改方阅读使用  

class appData:
    ''' 配置项 '''
    
    # 系统配置
    app_name='图纸校审工具CheckTool'
    app_ver= 'ver:  1.0'
    about= None
    copyright= """
--------------------------------------------------------------------------------
                            Autor:       terrasky
                            Date:        2024-09-20
                copyright: (c) 2024 by Terrasky All rights reserved.
--------------------------------------------------------------------------------
说明：
1、本系统默认校审图层为'Revise'，校审框请在此图层下绘制；
2、校审框对象只能为PLine对象，其他图形对象不予识别。
"""
    default_lay='Revise'
    excel_file_name = '常用知识/知识库.xlsx'
    seqs = ('说明','规范依据','依据内容','标签','用户名')
    seqs_id = ('context','gui','guiCont','tagname','userName')
    key_names = ('id','file','type','context','gui','guiCont','tagname','hothit','userName')
    _filename = 'appConfig.js'
    type_model = appModel.FILE

    _Config = {
        'AUTOR' : 'GJQ',
    }

    @classmethod
    def save(cls):
        try:
            with open(cls._filename,'w',encoding="UTF-8-sig") as f:
                json.dump(cls._Config, f,indent=4)
            return True
        except:
            return False

    @classmethod
    def load(cls):
        try:
            with open(cls._filename,'r',encoding="UTF-8-sig",newline="") as f:
                data = json.load(f)
                cls._Config.update(data)
            return True
        except FileNotFoundError:
            return False

    @classmethod
    def initDataFile(cls):
        try:
            with open(cls._filename,'w',encoding="UTF-8-sig") as f:
                json.dump(cls._Config, f,indent=4)
        except:
            return False
        return True


appData = appData()

if __name__ == "__main__":
    appData.initDataFile()

